﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using PayRoller.Code;
using System.Web.SessionState;

namespace PayRoller.Manage.Reports
{
    public partial class InvoiceReportSetting : ParentPage, IRequiresSessionState
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack == false)
            {
                this.DisplaySettingsStatus();
            }
        }

        private void DisplaySettingsStatus()
        {
            ReportSettingsBN business = new ReportSettingsBN(this.Page);
            ReportSettingsInvoiceDT setting = business.GetReportSettingsInvoice(0);
            if (setting != null)
            {
                this.cbClientName.Checked = setting.IsDisplayOrgName;
                this.cbOurReference.Checked = setting.IsDisplaySystemReference;
                this.cbAmountCharged.Checked = setting.IsDisplayAmountCharged;
                this.cbAmountReceived.Checked = setting.IsDisplayAmountReceived;
                this.cbBalance.Checked = setting.IsDisplayBalance;
                this.cbDateOfInvoice.Checked = setting.IsDisplayDateOfInvoice;
                this.cbFinanceCost.Checked = setting.IsDisplayFinanceCost;
                this.cbInvoiceDueDate.Checked = setting.IsDisplayInvoiceDueDate;
                this.cbInvoiceList.Checked = setting.IsDisplayInvoiceList;
                this.cbLateInterest.Checked = setting.IsDisplayLateInterest;
                this.cbNetPay.Checked = setting.IsDisplayNetPay;
                this.cbPenalty.Checked = setting.IsDisplayPenalty;
                this.cbStatusOfInvoice.Checked = setting.IsDisplayStatusOfInvoice;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            ReportSettingsInvoiceDT setting = new ReportSettingsInvoiceDT();
            setting.UserID = 0;
            setting.IsDisplayOrgName = this.cbClientName.Checked;
            setting.IsDisplaySystemReference = this.cbOurReference.Checked;

             setting.IsDisplayAmountCharged=this.cbAmountCharged.Checked;
             setting.IsDisplayAmountReceived=this.cbAmountReceived.Checked;
             setting.IsDisplayBalance=this.cbBalance.Checked;
             setting.IsDisplayDateOfInvoice=this.cbDateOfInvoice.Checked;
             setting.IsDisplayFinanceCost=this.cbFinanceCost.Checked;
             setting.IsDisplayInvoiceDueDate=this.cbInvoiceDueDate.Checked;
             setting.IsDisplayInvoiceList=this.cbInvoiceList.Checked;
             setting.IsDisplayLateInterest=this.cbLateInterest.Checked;
             setting.IsDisplayNetPay=this.cbNetPay.Checked;
             setting.IsDisplayPenalty=this.cbPenalty.Checked;
             setting.IsDisplayStatusOfInvoice=this.cbStatusOfInvoice.Checked;

            ReportSettingsBN business = new ReportSettingsBN(this.Page);
            business.OperateReportSettingsInvoice(setting);
        }
    }
}
